from django.contrib import admin
from Merchant.models import Additionaldiscount, Agent, Agentcompany, Bonus, Company, Contactinformation, Custom, Insurance, Insurancecoefficient, Orderbonus, Orderimage, Orderinsurance, Policyorder
# Register your models here.
class AdditionalDiscountInline(admin.TabularInline):
    model = Additionaldiscount
    extra = 3

class AgentCompanyInline(admin.TabularInline):
    model = Agentcompany
    extra = 3

class ContactInformationInline(admin.TabularInline):
    model = Contactinformation
    extra = 3

class InsuranceCoefficientInline(admin.TabularInline):
    model = Insurancecoefficient
    extra = 3

class OrderBonusInline(admin.TabularInline):
    model = Orderbonus
    extra = 3

class OrderImageInline(admin.TabularInline):
    model = Orderimage
    extra = 3

class OrderInsuranceInline(admin.TabularInline):
    model = Orderinsurance
    extra = 3

class PolicyOrderInline(admin.TabularInline):
    model = Policyorder
    extra = 3

class AgentAdmin(admin.ModelAdmin):
    search_fields = ['name']
    inlines = [AgentCompanyInline,PolicyOrderInline]
    list_display = ('name', 'telephone',)

class AgentCompanyAdmin(admin.ModelAdmin):
    search_fields = ['agentcompanyid']
    inlines = [AdditionalDiscountInline]
    list_display = ('agentcompanyid', 'discount1', 'discount2',)

class BonusAdmin(admin.ModelAdmin):
    search_fields = ['bonusid']
    inlines = [OrderBonusInline]

class CompanyAdmin(admin.ModelAdmin):
    search_fields = ['fullname']
    inlines = [AgentCompanyInline,InsuranceCoefficientInline,PolicyOrderInline]
    list_display = ('fullname', 'companyid',)

class ContactInformationAdmin(admin.ModelAdmin):
    inlines = [PolicyOrderInline]
    list_display = ('name', 'phone', 'gender',)

class CustomAdmin(admin.ModelAdmin):
    inlines = [ContactInformationInline,PolicyOrderInline]

class InsuranceAdmin(admin.ModelAdmin):
    inlines = [OrderInsuranceInline, InsuranceCoefficientInline]
    list_display = ('insuranceid', 'type',)

class PolicyOrderAdmin(admin.ModelAdmin):
    inlines = [OrderBonusInline, OrderImageInline, OrderInsuranceInline]
    list_display = ('customid', 'companyid',)


admin.site.register(Agent, AgentAdmin)
admin.site.register(Agentcompany, AgentCompanyAdmin)
admin.site.register(Bonus, BonusAdmin)
admin.site.register(Company, CompanyAdmin)
admin.site.register(Contactinformation, ContactInformationAdmin)
admin.site.register(Custom, CustomAdmin)
admin.site.register(Insurance, InsuranceAdmin)
admin.site.register(Policyorder,PolicyOrderAdmin)